﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html style="height: 100%;>
<head>
<meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport" />
<meta http-equiv="Content-Type" content=text/html; charset=utf-8" />
<title>在线问答机器人</title>

<link rel="stylesheet" type="text/css" href="teacher/css/default.css" />

<link href="teacher/css/index.css" rel="stylesheet" />

<link href="teacher/font/iconfont.css" rel="stylesheet" />
<script type="text/javascript" src="teacher/js/jquery.min.js"/>
<script type="text/javascript" src="teacher/js/script.js"/>
</head>

<body style="height:100%;">

    <div class="boxer" style="z-index: 11;">
		<canvas id="bgcanvas"></canvas>
		<h2 class="logo"><img src="teacher/images/logo.png"/></h2>
		<div class="box1" >
		    <div class="middle1" style="z-index: 99;">
		    	<div class="middle_left">
		    		<img src="teacher/images/login-img.png" />
		    	</div>
		    	<div class="middle_right" >
		    		<div class="mr_box">
		    			<h3>您好，老师！欢迎登录</h3>
						<form class="layui-form">
							<div class="form-group">
								<span class="iconfont icon-Profile icon_p"></span>
								  <input type="text" class="form-control icon-user" name="teachernum" placeholder="请输入您的工号">
							</div>
							<div class="form-group mar_b">
								<span class="iconfont icon-Unlock icon_p"></span>
								  <input type="password" class="form-control icon-pass" name="password" placeholder="请输入您的密码">
							</div>

							<button type="button" class="login" lay-submit lay-filter="LAY-user-login-submit">登录</button>
						</form>
		            </div>
		    	</div>
		    </div>
		</div>
    </div>
</body>
</html>

<script>
	layui.use(['admin', 'form', 'user','baseSetting','brand'], function(){
		var $ = layui.$
				,brand = layui.brand
				,setter = layui.setter
				,admin = layui.admin
				,form = layui.form
				,router = layui.router()
				,search = router.search
				,proPath = layui.baseSetting.brandConfig.proApi;

		form.render();
		//提交
		form.on('submit(LAY-user-login-submit)', function(obj){
			//请求登入接口
			admin.req({
				url: proPath+'/admin/teacher/login' //实际使用请改成服务端真实接口
				,type : 'POST'
				,data: obj.field
				,error:function(err){
					layer.msg(err.responseJSON.message, {
						offset: '15px'
						,icon: 2
					});
				}
				,done: function(res){
					if(res.status == '200'){
						//请求成功后，写入 access_token
						layui.data(setter.tableName, {
							key: setter.request.tokenName
							,value: res.data.token
						});



						//登入成功的提示与跳转
						layer.msg('登入成功', {
							offset: '15px'
							,icon: 1
							,time: 1000
						}, function(){
							location.hash = search.redirect ? decodeURIComponent(search.redirect) : '/';
						});
					}else{
						brand.alert.error(res.message);
					}

				}
			});
		});
	});
</script>

